﻿'    Open Subtitle Editor
'    Copyright (c) 2009-2010 Discovery OSS Team
'
'    This file is part of Open Subtitle Editor.
'
'    Open Subtitle Editor is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.
'
'    Open Subtitle Editor is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.
'
'    You should have received a copy of the GNU General Public License
'    along with Open Subtitle Editor.  If not, see <http://www.gnu.org/licenses/>.

Public Class frmPreviewSettings

    Private Sub frmPreviewSettings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        nudStartDelay.Value = My.Computer.Registry.GetValue(AppRegKey, "StartDelay", 0)
        nudEndDelay.Value = My.Computer.Registry.GetValue(AppRegKey, "EndDelay", 0)
        nudAddDelay.Value = My.Computer.Registry.GetValue(AppRegKey, "AddDelay", 0)
        chkStopOnEndOfSub.Checked = My.Computer.Registry.GetValue(AppRegKey, "stopOnEndOfSub", True)

    End Sub

    Public Sub LoadLangStrings()
        lblAddDelay.Text = loadStringFromLangFile("addDelay")
        lblEndDelay.Text = loadStringFromLangFile("endDelay")
        lblStartDelay.Text = loadStringFromLangFile("startDelay")
        chkStopOnEndOfSub.Text = loadStringFromLangFile("stopOnEndOfSub")
        btnCancel.Text = loadStringFromLangFile("cancelButton")
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        My.Computer.Registry.SetValue(AppRegKey, "StartDelay", nudStartDelay.Value)
        My.Computer.Registry.SetValue(AppRegKey, "EndDelay", nudEndDelay.Value)
        My.Computer.Registry.SetValue(AppRegKey, "AddDelay", nudAddDelay.Value)
        My.Computer.Registry.SetValue(AppRegKey, "stopOnEndOfSub", chkStopOnEndOfSub.Checked)

        frmMain.LoadSettings()
    End Sub

    Private Sub chkStopOnEndOfSub_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkStopOnEndOfSub.CheckedChanged
        If chkStopOnEndOfSub.Checked = True Then
            nudStartDelay.Enabled = True
            nudEndDelay.Enabled = True
        Else
            nudStartDelay.Enabled = False
            nudEndDelay.Enabled = False
        End If
    End Sub
End Class